import { defineStore } from 'pinia';

interface InventoryItem {
	id: number;
	name: string;
	stock: number;
	// 其他字段...
}

export const useGoodsStore = defineStore('goods', {
	state: () => ({
		inventory: [] as InventoryItem[],
		dailySales: 0,
	}),
	actions: {
		async fetchInventory() {
			// 实际项目中从API获取数据
			this.inventory = [
				{ id: 1, name: '牛奶', stock: 5 },
				// 其他商品...
			];
		},
	},
	getters: {
		lowStockItems(): InventoryItem[] {
			return this.inventory.filter((item) => item.stock < 10);
		},
	},
});
